import java.io.FileNotFoundException;
import java.io.IOException;

/**
 * Created by xiebang
 * Description
 * User:小谢
 * Date:2021-09-22
 * Time:19:22
 */
class MyException extends RuntimeException{
    public MyException(){
        super();
    }
    public MyException(String message){
        super(message);
    }
}

class UserException extends Exception {
    public UserException(String message) {
        super(message);
    }
}
class PasswordException extends Exception {
    public PasswordException(String message) {
        super(message);
    }
}
public class TesrDemo {

    public static void func2() throws MyException{
        int a = 10;
        if (a == 10) {
            throw new MyException("输出异常信息");
        }
    }

    public static void main(String[] args) {
        try {
            func2();
        }catch (MyException ex){
            System.out.println();
        }
    }
    //非受查异常是运行时异常    受查异常是编译时异常
    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }

    //一般情况strows一般都是编译时异常
    public static void func() throws RuntimeException,NullPointerException{
        int a = 10;
        if (a == 10) {
            throw new MyException("aaaaa");
        }
    }

    public static void main1(String[] args) {
        try {
            func();
        }catch (RuntimeException ex){
            System.out.println("抛出了一个异常");

        }
        System.out.println("fafafafa");
    }
    public void getCustomerInfo() {

        try {

            // do something that may cause an Exception
            throw new IOException();
        } catch (java.io.FileNotFoundException ex) {

            System.out.print("FileNotFoundException!");

        } catch (java.io.IOException ex) {

            System.out.print("IOException!");

        } catch (java.lang.Exception ex) {

            System.out.print("Exception!");

        }

        //最上面写子类，下面写父类

    }
}
